package cn.lingyangwl.framework.data.mate.fieldsensitive;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

import java.util.HashSet;
import java.util.Set;

/**
 * @deprecated
 * @author shenguangyang
 */
@Slf4j
public class FieldSensitiveScanRegistrar implements ImportBeanDefinitionRegistrar {
    public static Set<String> SCAN_BASE_PACKAGES = new HashSet<>();

    @Override
    @SuppressWarnings({"unchecked", "Duplicates"})
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
//        String rootPackageName = ClassUtils.getPackageName(importingClassMetadata.getClassName());
//        Map<String, Object> attributes = importingClassMetadata.getAnnotationAttributes(FieldSensitiveScan.class.getName());
//        if (!Objects.isNull(attributes)) {
//            String[] basePackages = (String[]) attributes.get("basePackages");
//            String[] basePackagesFromValue = (String[]) attributes.get("value");
//            if (basePackages.length == 0 && basePackagesFromValue.length == 0) {
//                SCAN_BASE_PACKAGES.add(rootPackageName);
//            } else {
//                Set<String> basePackagesSet = new HashSet<>(Arrays.asList(basePackages));
//                Set<String> basePackagesFromValueSet = new HashSet<>(Arrays.asList(basePackagesFromValue));
//                basePackagesSet.addAll(basePackagesFromValueSet);
//                SCAN_BASE_PACKAGES.addAll(basePackagesSet);
//            }
//        }
    }
}
